import greenfoot.*; 
public class Worm extends Actor
{
    public void act() 
    {
        move(5);
        randomTurn();
        turnAtEdge();
    }
    public void randomTurn(){
        if(Greenfoot.getRandomNumber(100)<50){
            turn(Greenfoot.getRandomNumber(80)-40);
        }
    }
    public void turnAtEdge(){
        if(isAtEdge()){
            turn(Greenfoot.getRandomNumber(180)-90);
        }
    }
}